package com.zhangzeqin.code.controller;

import com.zhangzeqin.code.dao.GetWordDao;
import com.zhangzeqin.code.dao.Impl.WordBookDaoImpl;
import com.zhangzeqin.code.dao.WordBookDao;
import com.zhangzeqin.code.entity.WordBook;
import com.zhangzeqin.code.service.Impl.WordBookServiceImpl;
import com.zhangzeqin.code.service.WordBookService;

import java.sql.SQLException;
import java.util.List;
import java.util.Map;

/**
 * @author 张泽钦
 */
public class WordBookController {
    /**
     * 实例化一个WordBookService对象
     */
    WordBookService wordBookService=new WordBookServiceImpl();

    public WordBookController() {
    }

    public WordBookController(WordBookService wordBookService) {
        this.wordBookService = wordBookService;
    }


    /**
     * 添加单词书
     * @param bookName
     * @return boolean结果
     */
    public boolean addBook(String bookName,String nature) {
        return wordBookService.addBook(bookName,nature);
    }

    /**
     * 删除单词书
     * @param bookName 书名
     */
    public boolean deleteBook(String bookName) throws SQLException {
        return wordBookService.deleteBook(bookName);
    }
    /**
     * 查找单词
     * @param wordBook 单词书名
     * @param word 单词
     * @param meaning 意思
     * @return 返回一个boolean值
     */
    public boolean checkWord(String wordBook, String word, String meaning) {
        return wordBookService.checkWord(wordBook,word,meaning);
    }

    /**
     * 获得单词
     * @param table 表名
     * @return 一个结果集对象
     */

    public List<Map> getWord(String table) throws SQLException{
        return wordBookService.getWord(table);
    }


}
